4.2 Appendix B : Control Key – TransactionStatusCompletedURL
The ControlKey form variable passed back to the merchant for the TransactionStatusCompletedURL is calculated using the following algorithm.
Values in angle brackets correspond to the values of the form variables with the name contained therein.
The [Shared Encryption Key/Merchant Encryption key] value will be a key shared with the merchant from payment gateway.
private string CreateTheControlKey_TransactionStatusCompletedURL() {
string functionResult = string.Empty;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(string.Format("{0}={1};", "MerchantIdentifier", ));
sb.Append(string.Format("{0}={1};", "MerchantReference", ));
sb.Append(string.Format("{0}={1};", "CorrelationIdentifier", ));
sb.Append(string.Format("{0}={1};", "CustomerIdentifier", ));
sb.Append(string.Format("{0}={1};", "CardNumber", ));
sb.Append(string.Format("{0}={1};", "Amount", ));
sb.Append(string.Format("{0}={1};", "TransactionReference", ));
sb.Append(string.Format("{0}={1};", "ErrorCode", ));
sb.Append(string.Format("{0}={1};", "ErrorDescription", ));
sb.Append(string.Format("{0}={1};", "BankReference", ));
sb.Append(string.Format("{0}={1};", "BankResponseCode", ));
sb.Append(string.Format("{0}={1}", "BankResponseDescription", ));
functionResult = this.EncryptTheControlKey(sb.ToString(), [Shared Encryption Key]);
return functionResult;
}
private string EncryptTheControlKey(string message, string publicKey) {
{
string functionResult = string.Empty;
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] keyByte = encoding.GetBytes(publicKey);
HMACSHA256 hmacsha256 = new HMACSHA256(keyByte);
byte[] messageBytes = encoding.GetBytes(message);
byte[] hashmessage = hmacsha256.ComputeHash(messageBytes);
functionResult = ByteToString(hashmessage);
return functionResult;
}
Figure 30. Control Key Encryption – TransactionStatusCompletedURL
Continue
Return